package cn.com.demo.microservice.vo;

import cn.com.demo.microservice.entity.AqAccount;
import cn.com.demo.microservice.entity.AqUser;
import org.springframework.cglib.beans.BeanCopier;

public final class ConvertTools {
     private static BeanCopier user2PoCopier = BeanCopier.create(User.class, AqUser.class, false);
     private static BeanCopier user2VoCopier = BeanCopier.create(AqUser.class, User.class, false);
     private static BeanCopier account2PoCopier = BeanCopier.create(Account.class, AqAccount.class, false);
     private static BeanCopier account2VoCopier = BeanCopier.create(AqAccount.class, Account.class, false);

     public static AqAccount convert2Po(Account account){
         AqAccount aqAccount = null;
         try {
             aqAccount = new AqAccount();
             account2PoCopier.copy(account, aqAccount, null);
         }catch (Exception e){
             throw new RuntimeException(e);
         }
         return aqAccount;
     }

    public static AqUser convert2Po(User account){
        AqUser aqAccount = null;
        try {
            aqAccount = new AqUser();
            user2PoCopier.copy(account, aqAccount, null);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
        return aqAccount;
    }
}
